package com.example.administrator.q1;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/9/1.
 */

public class FragmentTwo extends Fragment{

    GridView gridView;
    List<People> list = new ArrayList<People>();

    int[] images = new int[]{R.mipmap.ic_launcher_round,R.mipmap.ic_launcher_round,R.mipmap.ic_launcher_round,R.mipmap.ic_launcher_round,R.mipmap.ic_launcher_round,R.mipmap.ic_launcher_round,R.mipmap.ic_launcher_round,R.mipmap.ic_launcher_round,R.mipmap.ic_launcher_round,R.mipmap.ic_launcher_round,R.mipmap.ic_launcher_round,R.mipmap.ic_launcher_round,R.mipmap.ic_launcher_round,R.mipmap.ic_launcher_round,R.mipmap.ic_launcher_round,R.mipmap.ic_launcher_round};
    String [] name= {"Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android","Android", "Android", "Android", "Android", "Android", "Android", "Android"};

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_fragment_two, null);

        gridView = (GridView) view.findViewById(R.id.gridView);

        for (int i = 0; i < images.length; i++) {
            People people = new People();
            people.setName(name[i]);
            people.setImg(images[i]);
            list.add(people);
        }


        MyGridViewAdapter myGridViewAdapter = new MyGridViewAdapter(getActivity(), list);

        gridView.setAdapter(myGridViewAdapter);


        return view;
    }
}
